var express = require('express');
var router = express.Router();
//引入数据库操作方法
var {getUser,findUser} = require('../dataBase/api')
/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});
//查询所有用户
router.get('/getAllUser',async function(req, res, next) {
  let data =await getUser(); // 查询数据
  res.success(data[0]);//返回数据
});

//查询单个用户
router.get('/findUser',async function(req, res, next) {
  //根据用户ID查询单个用户
  let {username} = req.query
  let data =await findUser(username);
  res.success(data[0]);//返回数据
})




module.exports = router;
